﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Portal.Web.Model;
using Portal.Cms.Model;
using Portal.Cms.Bussiness;
using Portal.Web.Utility;
using Portal.Cms.Utility;
using Portal.Core;

namespace Portal.Cms.Render
{
    public class DocHomeRenderBll
    {
        public static AjaxOut Draw(string SiteId)
        {
            AjaxOut OAjaxOut = new AjaxOut();
            try
            {
                string gid = (string)WebEnvironments.Request(SiteId, "gid");
                if (string.IsNullOrEmpty(gid)) throw new Exception("Tham số truy cập không hợp lệ!");
                GroupDataCls OGroupData = CmsUtility.CreateCmsBussinessProcess(SiteId).CreateCmsProcess(SiteId).CreateGroupDataModel(null, SiteId, gid);
                if (OGroupData == null)
                {
                    throw new Exception("Tham số truy cập không hợp lệ!");
                }
                string Html =
                   "<div class=FormFunction>\r\n" +
                   "    <h3>" + OGroupData.GroupDataName + "</h3>\r\n" +
                   "    <div class=body>\r\n" +
                   "        <div style=\"margin-top:2px;text-align:left;padding:8px;font-size:22px;\">\r\n" +
                   "            <div style=\"font-size:16px;margin-top:4px;padding:4px;color:Gray;font-style:italic\">Chào mừng bạn đã đến với chức năng quản lý văn bản tài liệu</div>\r\n" +
                   "        </div>\r\n" +
                   "        <div class=divInfo>\r\n" +
                   "            <ul>\r\n" +
                   "                <li class=liDocumentType onclick=\"window.open('DocumentType.aspx?gid="+gid+"','_self');\">\r\n" +
                   "                    <div><img style=\"height:60px;\" src=\"Resources/Images/menu.png\"></div>\r\n" +
                   "                    <div>Loại văn bản</div>\r\n" +
                   "                </li>\r\n" +
                   "                <li class=liDocumentSigner onclick=\"window.open('DocumentSigner.aspx?gid="+gid+"','_self');\">\r\n" +
                   "                    <div><img style=\"height:60px;\" src=\"Resources/Images/Signer.png?gid="+gid+"'\"></div>\r\n" +
                   "                    <div>Người ký</div>\r\n" +
                   "                </li>\r\n" +
                   "                <li class=liDocumentReleaseFrom onclick=\"window.open('DocumentReleaseFrom.aspx?gid="+gid+"','_self');\">\r\n" +
                   "                    <div><img style=\"height:60px;\" src=\"Resources/Images/group.png\"></div>\r\n" +
                   "                    <div>Cơ quan ban hành</div>\r\n" +
                   "                </li>\r\n" +
                   "                <li class=liDocumentField onclick=\"window.open('DocumentField.aspx?gid=" + gid + "','_self');\">\r\n" +
                   "                    <div><img style=\"height:60px;\" src=\"Resources/Images/document.png\"></div>\r\n" +
                   "                    <div>Lĩnh vực</div>\r\n" +
                   "                </li>\r\n" +
                   "                <li class=liDocumentYear onclick=\"window.open('DocumentYearRange.aspx?gid=" + gid + "','_self');\">\r\n" +
                   "                    <div><img style=\"height:60px;\" src=\"Resources/Images/Year.png\"></div>\r\n" +
                   "                    <div>Khoảng thời gian</div>\r\n" +
                   "                </li>\r\n" +
                   "                <li class=liDocumentRelationType onclick=\"window.open('DocumentRelationType.aspx?gid=" + gid + "','_self');\">\r\n" +
                   "                    <div><img style=\"height:60px;\" src=\"Resources/Images/document.png\"></div>\r\n" +
                   "                    <div>Kiểu quan hệ</div>\r\n" +
                   "                </li>\r\n" +

                   //"                <li class=liDocument onclick=\"window.open('Documents.aspx?gid="+gid+"','_self');\">\r\n" +
                   //"                    <div><img style=\"height:60px;\" src=\"Resources/Images/html.png\"></div>\r\n" +
                   //"                    <div>Quản lý văn bản</div>\r\n" +
                   //"                </li>\r\n" +

                   "                <li class=liBack onclick=\"window.open('GroupData.aspx?datatype=document','_self');\">\r\n" +
                   "                    <div><img style=\"height:60px;\" src=\"Resources/Images/back.png\"></div>\r\n" +
                   "                    <div>Quay lại</div>\r\n" +
                   "                </li>\r\n" +
                   "            </ul>\r\n" +
                   "        </div>\r\n" +
                   "    </div>\r\n" +
                   "</div>\r\n";

                OAjaxOut.HtmlContent = Html;
            }
            catch (Exception ex)
            {
                OAjaxOut.InfoMessage = ex.Message.ToString();
                OAjaxOut.HtmlContent = ex.Message.ToString();
            }
            
            return OAjaxOut;
        }




        public static AjaxOut DrawDocumentInput(string SiteId)
        {
            AjaxOut OAjaxOut = new AjaxOut();
            try
            {
                GroupDataCls[] GroupDatas = CmsUtility.CreateCmsBussinessProcess(SiteId).CreateCmsProcess(SiteId).ReadingGroupDataForInput(SiteId, "document");
                string Html =
                   "<div class=FormFunction>\r\n" +
                   "    <h3>Nhập văn bản tài liệu</h3>\r\n" +
                   "    <div class=body>\r\n" +
                   "        <div style=\"margin-top:2px;text-align:left;padding:8px;font-size:22px;\">\r\n" +
                   "            <div style=\"font-size:16px;margin-top:4px;padding:4px;color:Gray;font-style:italic\">Chào mừng bạn đã đến với chức năng quản lý văn bản tài liệu</div>\r\n" +
                   "        </div>\r\n" +
                   "        <div class=divInfo>\r\n" +
                   "            <ul>\r\n";
                for (int iIndex = 0; iIndex < GroupDatas.Length; iIndex++)
                {
                    string gid = GroupDatas[iIndex].GroupDataId;
                    Html +=
                       "                <li class=liDocumentType onclick=\"window.open('Documents.aspx?gid=" + gid + "','_self');\">\r\n" +
                       "                    <div><img style=\"height:60px;\" src=\"Resources/Images/Document.png\"></div>\r\n" +
                       "                    <div>" + GroupDatas[iIndex].GroupDataName + "</div>\r\n" +
                       "                </li>\r\n";
                }
                Html+=
                   "                <li class=liBack onclick=\"window.open('../Home.aspx','_self');\">\r\n" +
                   "                    <div><img style=\"height:60px;\" src=\"Resources/Images/back.png\"></div>\r\n" +
                   "                    <div>Quay lại</div>\r\n" +
                   "                </li>\r\n" +
                   "            </ul>\r\n" +
                   "        </div>\r\n" +
                   "    </div>\r\n" +
                   "</div>\r\n";

                OAjaxOut.HtmlContent = Html;
            }
            catch (Exception ex)
            {
                OAjaxOut.InfoMessage = ex.Message.ToString();
                OAjaxOut.HtmlContent = ex.Message.ToString();
            }

            return OAjaxOut;
        }
    }
}
